package two.chapter_1.c1_2;

import edu.princeton.cs.algs4.StdOut;
import edu.princeton.cs.algs4.StdRandom;

public class Ex1_2_2 {

    public static void main(String [] args){

        int N=10;
        Interval1D[] intervals=new Interval1D[N];
        for (int i=0;i<N;i++){
            intervals[i]=new Interval1D(StdRandom.uniform(),StdRandom.uniform());
        }

        for (int i=0;i<N-1;i++){
            for (int j=i+1;j<N;j++){
                boolean intersect=intervals[i].intersect(intervals[j]);
                if (intersect){
                    StdOut.println("第"+i+"个和第"+j+"个相交");
                }
            }
        }

    }
}
